// pages/index.js
//取app.jszhongdeshuju
var app = getApp()
const HOST = app.globalData.host

Page({
  imgUrls:[
    "/pages/images/haibao/1.jpg",
    "/pages/images/haibao/2.jpg",
    "/pages/images/haibao/3.jpg",
  ],
  data: {
    rmjsList: [],
    msskList: [],
    cxsjList: [],
  },
  
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.showTabBarRedDot({
      index: 1,
    })
    wx.setTabBarBadge({
      index: 2,
      text: 'aa',
    })
    wx.showLoading()  
    this.getBookList();
  },
  getBookList(){
    var page = this
    wx.request({
      url: HOST+'/api/goods/getHomeGoodsList',
      method:'GET',
      data:{},
      success(res){
        console.log(res)
        // page.data.rmjsList = res.data.data.rmjs
        page.setData({
          rmjsList:res.data.data.rmjs,
          msskList:res.data.data.mssk,
          cxsjList:res.data.data.cxsj
        })
      },
      complete(){
        wx.hideLoading({
          
        })
      }
    })
  },
  getMore(e){
    var id = e.currentTarget.id
    console.log(id)
    wx.navigateTo({
      url: '/pages/goods/goods?type='+id,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  change(e) {
    console.log(e.detail)
  },

  tap(e) {
      let id = e.target.dataset.id
      this.setData({
        current: id
      })     
  } 
})